package top.jamsee.dao;

import org.apache.ibatis.annotations.*;
import top.jamsee.entity.Buy_data;

import java.util.Date;
import java.util.List;

public interface BuyDao {
    //查看买房表的数据

    /*
     * 分页功能必须需要的sql查询
     *
     *
     * */
    //查看买房表的数据
    public List<Buy_data> selectBuyData();
    //根据id查询是否有此条记录,更新表时使用
    @Select("select count(0) from buy where id=#{id}")
    public int selectBuyById(@Param("id") int id);
    //查看buy表有多少条数据用于分页
    @Select("select count(0) from buy")
    public int selectBuyNum();
    //删除买房表的数据(按id)
    @Delete("delete from buy where id=#{id}")
    public int deleteBuyDataById(@Param("id") int id);
    //添加买房表数据
    @Insert("insert into buy (title,insert_time,operate_person,imgAddress,typeHouse_area,advantages,if_need_show)" +
            " values(#{title},#{insert_time},#{operate_person},#{imgAddress},#{typeHouse_area},#{advantages},#{if_need_show})")
    public int addBuyData(Buy_data buy_data);
    //模糊查询buy表
    @Select("SELECT * FROM `buy` where title LIKE CONCAT('%',#{data},'%')")
    public List<Buy_data> selectBuyByData(@Param("data") String data );
    //模糊查询buy表的所有数量方便后续分页
    @Select("SELECT count(0) FROM `buy` where title LIKE CONCAT('%',#{data},'%')")
    public int selectBuyByDataNum(@Param("data") String data );
    //更新buy表根据id
    @Update("Update buy set operate_person=#{operate_person},title=#{title},insert_time=#{insert_time}," +
            "imgAddress=#{imgAddress},typeHouse_area=#{typeHouse_area}" +
            ",advantages=#{advantages},if_need_show=#{if_need_show}" +
            "  where id=#{id};")
    public int upDateBuyById(Buy_data buy_data);






}
